<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use App\Models\Admin\Stats\Risk\Config;

class CreateStatsRiskConfigTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $tableName = Config::tableName();

        Config::schemaConnection()->create($tableName, function (Blueprint $table) {
            $table->id('id');
            $table->string('type', 16)->comment('类型')->index();
            $table->json('config')->comment('配置');

            $table->unsignedInteger('created');
            $table->unsignedInteger('updated');
        });

        Config::dbConnection()->statement("ALTER TABLE `{$tableName}` COMMENT '统计--预警--配置'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Config::schemaConnection()->dropIfExists(Config::tableName());
    }
}
